#include"Ring.hpp"
#include<cstdlib>
#include<ctime>
#include<unistd.h>
void* consumer(void* arg)
{
  RingQueue<int>* rq=(RingQueue<int>*) arg;
  while(1)
  {
    sleep(1);
    int x=0;
    rq->pop(x);
    printf("consumer done: %d\n",x);
  }
}

void* pruduct(void* arg)
{
  RingQueue<int>* rq=(RingQueue<int>*) arg;
  while(1)
  {
    int x= rand()%100;
    rq->push(x);

    printf("pruduct done: %d\n",x);
  }
}

int main()
{
  srand((unsigned long)time(nullptr));
 RingQueue<int> *rq=new RingQueue<int>();//创建环形队列
 pthread_t  c,p;
 
 pthread_create(&c,nullptr,consumer,(void*)rq);
 pthread_create(&p,nullptr,pruduct,(void*)rq);


pthread_join(c,nullptr);
pthread_join(p,nullptr);

return 0;
}
